package com.logansoft.zhxypkoa.repository.sys;

import java.util.Optional;

import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import org.springframework.data.rest.core.annotation.RestResource;

import com.logansoft.zhxypkoa.domain.sys.User;

@RepositoryRestResource(collectionResourceRel = "users", path = "users")
public interface UserRepository extends JpaRepository<User, String> {
	@RestResource(exported = false)
	public User findByUsernameAndPassword(@Param(value = "username") String username, @Param(value = "password") String password);
	@Cacheable(value = "users", key = "#p0")
	@Override
	Page<User> findAll(Pageable pageable);
	@CacheEvict(value = "users", key = "#p0.id", allEntries = true)
	@Override
	<S extends User> S save(S entity);
	@Cacheable(value = "users", key = "#p0")
	@Override
	Optional<User> findById(String id);
	@CacheEvict(value = "users", key = "#p0", allEntries = true)
	@Override
	void deleteById(String id);
	@CacheEvict(value = "users", key = "#p0.id", allEntries = true)
	@Override
	void delete(User entity);
}